class CreateSalesFirms < ActiveRecord::Migration[5.1]
  def change
    create_table :sales_firms do |t|
      t.integer :customer_id, comment: '对应客户'
      t.string :name, comment: '公司名'
      t.integer :province_id, comment: '省份'
      t.integer :city_id, comment: '城市'
      t.string :short_name, comment: '字号'
      t.string :address, comment: '地址'
      t.string :website, comment: '网址'
      t.string :phone, comment: '电话'
      t.string :fax, comment: '传真'
      t.string :email, comment: '邮箱'
      t.integer :rating, comment: '客户评级'
      t.integer :parent_id, comment: '母公司'
      t.string :notes, limit: 4000, comment: '公司备注'

      t.timestamps

    end
    add_index :sales_firms, :name
    add_index :sales_firms, :customer_id
    add_index :sales_firms, :province_id
    add_index :sales_firms, :city_id
    add_index :sales_firms, :short_name
    add_index :sales_firms, :rating
    add_index :sales_firms, :website
    add_index :sales_firms, :phone
    add_index :sales_firms, :email
  end
end
